<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>e网生活管理后台</title>
  <?php include("common/conn.php"); if($_SESSION['userid']==""){echo "<script>window.location.href='login.php';</script>";} 

  if($_GET['action']=="ok")
  {    
    if ($_POST[ht_can_return]=='0') {
      $ht_return_time=0;
      $ht_return_confirm_time=0;
    }else{
      $ht_return_time=$_POST[ht_return_time];
      $ht_return_confirm_time=$_POST[ht_return_confirm_time];
    }

    if ($_POST[kg_can_return]=='0') {
      $kg_return_time=0;
      $kg_return_confirm_time=0;
    }else{
      $kg_return_time=$_POST[kg_return_time];
      $kg_return_confirm_time=$_POST[kg_return_confirm_time];
    }

    if ($_POST[support_ht] == '0') {
      $ht_confirm_time=0;
    }else{
      $ht_confirm_time=$_POST[kg_confirm_time];
    }
    if ($_POST[support_kg] == '0') {
      $kg_confirm_time=0;
    }else{
      $kg_confirm_time=$_POST[kg_confirm_time];
    }

    $srat=mysql_query("INSERT INTO categroy_type(type,rates,support_ht,is_logistics,ht_can_return,ht_return_time,ht_return_confirm_time,ht_confirm_time,support_kg,kg_can_return,kg_return_time,kg_return_confirm_time,kg_confirm_time) VALUES ('$_POST[type]','$_POST[rates]','$_POST[support_ht]','$_POST[is_logistics]','$_POST[ht_can_return]','$ht_return_time','$ht_return_confirm_time','$ht_confirm_time','$_POST[support_kg]','$_POST[kg_can_return]','$kg_return_time','$kg_return_confirm_time','$kg_confirm_time')");
    echo "<script>alert('添加成功');window.location.href='fenlei_leixing.php';</script>";
  }




  if($_GET['ch']=="ok")
  { 
    if ($_POST[ht_can_return]=='0') {
      $ht_return_time=0;
      $ht_return_confirm_time=0;
    }else{
      $ht_return_time=$_POST[ht_return_time];
      $ht_return_confirm_time=$_POST[ht_return_confirm_time];
    }

    if ($_POST[kg_can_return]=='0') {
      $kg_return_time=0;
      $kg_return_confirm_time=0;
    }else{
      $kg_return_time=$_POST[kg_return_time];
      $kg_return_confirm_time=$_POST[kg_return_confirm_time];
    }

    if ($_POST[support_ht] == '0') {
      $ht_confirm_time=0;
    }else{
      $ht_confirm_time=$_POST[ht_confirm_time];
    }
    if ($_POST[support_kg] == '0') {
      $kg_confirm_time=0;
    }else{
      $kg_confirm_time=$_POST[kg_confirm_time];
    } 
    $srat1=mysql_query("update categroy_type set type='".$_POST['type']."',rates='".$_POST['rates']."',support_ht='".$_POST[support_ht]."',is_logistics='".$_POST['is_logistics']."',ht_can_return='".$_POST['ht_can_return']."',ht_return_time='".$ht_return_time."',ht_return_confirm_time='".$ht_return_confirm_time."',ht_confirm_time='".$ht_confirm_time."',support_kg='".$_POST[support_kg]."',kg_can_return='".$_POST['kg_can_return']."',kg_return_time='".$kg_return_time."',kg_return_confirm_time='".$kg_return_confirm_time."',kg_confirm_time='".$kg_confirm_time."' where id='".$_REQUEST['id']."'");

    echo "<script>alert('更新成功');window.location.href='fenlei_leixing.php';</script>";
  }

  if($_GET['id']!=""){
    $rert30=mysql_query("select * from categroy_type where id='".$_GET['id']."'");
    $sdg30=mysql_fetch_array($rert30);
  }
  ?>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <link href="css/styles.css" rel="stylesheet" type="text/css" />
</head>

<body>

  <!--header-->
  <?php include("common/header.php");?>
  <!--header end-->


  <!-- staqrt subnav -->
  <div id="sub_nav">

    <div id="subnav_wrap" class="container_12">

      <!-- start sub nav list -->
      <div id="subnav" class=" grid_12">

        <ul>
          <li> <a href="fenlei.php"> 分类管理 </a></li>
          <li><a href="fenlei_leixing.php" class="sub_nav_active" >分类属性</a></li>
        </ul>

      </div>

    </div>


  </div>
  <div class="container_12">
    <form action="?<?php if($_GET['id']!=""){echo "ch=ok";}else{echo "action=ok";} ?>" method="post">
      <input type="hidden"  name="id"  value="<?php echo $sdg30[id];?>">
      <h2>添加分类属性</h2>  	
      <label>分类属性</label>
      <input name="type"  type="input"   value="<?php echo $sdg30[type];?>">
      <br/><br/>
      <label>返还率(百分之X)</label>
      <input name="rates"  type="input"  value="<?php echo $sdg30[rates];?>">
      <br/><br/>
<!-- 海淘 -->
  <div style="border:1px dashed #00769D;background-color: #C0DDE7;">
      <label>支持海淘</label>
      <input type="radio" name="support_ht" <?php if ($sdg30[support_ht] == 1 || !isset($_GET[id])) { ?> checked="checked" <?php } ?> value="1" class="support_ht">是
      <input type="radio" name="support_ht" <?php if ($sdg30[support_ht] == 0 && isset($_GET[id])) { ?> checked="checked" <?php } ?> value="0" class="notsupport_ht">否
      <br/><br/>
      <div class="ht-div" <?php if ($sdg30[support_ht] == 0 && isset($_GET[id])) { ?> style="display: none;" <?php } ?>>
        <label>用户订单自动确认收货时间</label>
        <input name="ht_confirm_time"  type="input" <?php if ($sdg30[ht_confirm_time]!=''){ ?> value="<?php echo $sdg30[ht_confirm_time];?>" <?php }else{?> value="15" <?php } ?>  >
        <label>天</label>
        <br/><br/>

        <label>是否显示物流</label>
        <input type="radio" name="is_logistics" value="1" <?php if ($sdg30[is_logistics] == 1) { ?> checked="checked" <?php } ?> >是
        <input type="radio" name="is_logistics" value="0" <?php if ($sdg30[is_logistics] == 0) { ?> checked="checked" <?php } ?> >否
        <br/><br/>
        <label>是否支持退货</label>
        <input type="radio" name="ht_can_return" <?php if ($sdg30[ht_can_return] == 1) { ?> checked="checked" <?php } ?> value="1" class="ht_can_return" checked="checked">是
        <input type="radio" name="ht_can_return" <?php if ($sdg30[ht_can_return] == 0) { ?> checked="checked" <?php } ?> value="0" class="ht_cannot_return">否
        <br/><br/>
        <div class="ht_return_div" <?php if ($sdg30[ht_can_return] == 0) { ?> style="display:none;" <?php } ?>>
          <label>允许退货最长时间</label>
          <input type="text" name="ht_return_time" <?php if ($sdg30[ht_can_return] == 0) { ?> disabled="disabled" <?php } ?> <?php if ($sdg30[ht_return_time]!='' && $sdg30[ht_return_time]!=0) { ?> value="<?php echo $sdg30[ht_return_time]; ?>" <?php }else{ ?> value="72" <?php } ?> class="ht_return_time">
          <label>小时</label>
          <br/><br/>
          <label>自动确认商家已回收时间</label>
          <input type="text" name="ht_return_confirm_time" <?php if ($sdg30[ht_can_return] == 0) { ?> disabled="disabled" <?php } ?> <?php if ($sdg30[ht_return_confirm_time]!=''  && $sdg30[ht_return_confirm_time]!=0) { ?> value="<?php echo $sdg30[ht_return_confirm_time]; ?>" <?php }else{ ?> value="15" <?php } ?> class="ht_return_confirm_time">
          <label>天</label>
          <br/><br/>
        </div>
      </div>
  </div>
<!-- 海淘 end -->

<!-- 快购 -->
  <div style="border:1px dashed #00769D;margin-top: 10px;background-color: #C0DDE7;">
    <label>支持快购</label>
    <input type="radio" name="support_kg" <?php if ($sdg30[support_kg] == 1 || !isset($_GET[id])) { ?> checked="checked" <?php } ?> value="1" class="support_kg">是
    <input type="radio" name="support_kg" <?php if ($sdg30[support_kg] == 0 && isset($_GET[id])) { ?> checked="checked" <?php } ?> value="0" class="notsupport_kg">否
    <br/><br/>

    <div class="kg-div" <?php if ($sdg30[support_kg] == 0 && isset($_GET[id])) { ?> style="display: none;" <?php } ?>>
      <label>用户订单自动确认收货时间</label>
      <input name="kg_confirm_time"  type="input" <?php if ($sdg30[kg_confirm_time]!=''){ ?> value="<?php echo $sdg30[kg_confirm_time];?>" <?php }else{?> value="15" <?php } ?>  >
      <label>天</label>
      <br/><br/>

      <label>是否支持退货</label>
      <input type="radio" name="kg_can_return" <?php if ($sdg30[kg_can_return] == 1) { ?> checked="checked" <?php } ?> value="1" class="kg_can_return" checked="checked">是
      <input type="radio" name="kg_can_return" <?php if ($sdg30[kg_can_return] == 0) { ?> checked="checked" <?php } ?> value="0" class="kg_cannot_return">否
      <br/><br/>
      <div class="kg_return_div" <?php if ($sdg30[kg_can_return] == 0) { ?> style="display:none;" <?php } ?>>
        <label>允许退货最长时间</label>
        <input type="text" name="kg_return_time" <?php if ($sdg30[kg_can_return] == 0) { ?> disabled="disabled" <?php } ?> <?php if ($sdg30[kg_return_time]!='' && $sdg30[kg_return_time]!=0) { ?> value="<?php echo $sdg30[kg_return_time]; ?>" <?php }else{ ?> value="72" <?php } ?> class="kg_return_time">
        <label>小时</label>
        <br/><br/>
        <label>自动确认商家已回收时间</label>
        <input type="text" name="kg_return_confirm_time" <?php if ($sdg30[kg_can_return] == 0) { ?> disabled="disabled" <?php } ?> <?php if ($sdg30[kg_return_confirm_time]!=''  && $sdg30[kg_return_confirm_time]!=0) { ?> value="<?php echo $sdg30[kg_return_confirm_time]; ?>" <?php }else{ ?> value="15" <?php } ?> class="kg_return_confirm_time">
        <label>天</label>
        <br/><br/>
      </div>
    </div>
  </div>
<!-- 快购 end -->

      <input  type="submit" value="提交" /></div>
    </form>       
  </div>
</form>
</body>
<script type="text/javascript">


// 支持海淘与否
  $('.support_ht').click(function(){
    $('.ht-div').css('display','block');
  });
  $('.notsupport_ht').click(function(){
    $('.ht-div').css('display','none');
  });
// 支持海淘与否 end

// 支持快购与否
  $('.support_kg').click(function(){
    $('.kg-div').css('display','block');
  });
  $('.notsupport_kg').click(function(){
    $('.kg-div').css('display','none');
  });
// 支持快购与否 end

// 支持海淘退货与否
  $('.ht_can_return').click(function(){
    $('.ht_return_time').removeAttr('disabled');
    $('.ht_return_confirm_time').removeAttr('disabled');
    $('.ht_return_div').css('display','block');
  });
  $('.ht_cannot_return').click(function(){
    $('.ht_return_time').attr('disabled','disabled');
    $('.ht_return_confirm_time').attr('disabled','disabled');
    $('.ht_return_div').css('display','none');
  });
// 支持海淘退货与否 end

// 支持海淘退货与否
  $('.kg_can_return').click(function(){
    $('.kg_return_time').removeAttr('disabled');
    $('.kg_return_confirm_time').removeAttr('disabled');
    $('.kg_return_div').css('display','block');
  });
  $('.kg_cannot_return').click(function(){
    $('.kg_return_time').attr('disabled','disabled');
    $('.kg_return_confirm_time').attr('disabled','disabled');
    $('.kg_return_div').css('display','none');
  });
// 支持海淘退货与否 end
</script>
</html>
